package com.itheima.sh.sk.test;

import com.itheima.sh.sk.pojo.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class Demo {
    public static void main(String[] args) throws IOException {
        SqlSessionFactoryBuilder factoryBuilder = new SqlSessionFactoryBuilder();
        InputStream resourceAsStream = Resources.getResourceAsStream("mybatis.xml");
        SqlSessionFactory sessionFactory = factoryBuilder.build(resourceAsStream);
        SqlSession sqlSession = sessionFactory.openSession();
        List<User> list = sqlSession.selectList("a.queryAllUsers");
        for (User user : list) {
            System.out.println(user);
        }
    }
}
